package com.lysj.admin.master.common.web;

import com.lysj.admin.master.common.enumeration.EnumInterface;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

import java.io.Serializable;

/**
 * @author soul 服务器向客户端响应的domain对象
 */
@Getter
@Slf4j
public class Resp<T> implements Serializable {

    @Getter
    @AllArgsConstructor
    public enum ResStatus implements EnumInterface {
        SUCCESS(200, "成功"),
        NO_LOGIN(401, "尚未登录"),
        NO_ACCESS(403, "尚未拥有权限"),
        PARAM_ERROR(412, "参数错误"),
        TOKEN_ERROR(422, "Token错误"),
        INNER_ERROR(500, "系统内部错误"),;

        private Integer code;
        private String status;
    }

    /**
     * 结果:结果码
     */
    private Integer code;

    /**
     * 提示信息
     */
    private String msg;

    /**
     * 响应的对象
     */
    private T data;

    public Resp(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

}
